import com.mobilerobots.Aria.*;

public class WallEExplorer
{

   //------------------------------------------------------------
   // ATRIBUTOS
   //------------------------------------------------------------

	private ArRobot WallE;
	private ArSimpleConnector conn;
	//Sensores
	private  touchSensor;
static {
    try {
        System.loadLibrary("AriaJava");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library libAriaJava failed to load. Make sure that its directory is in your library path; See javaExamples/README.txt and the chapter on Dynamic Linking Problems in the SWIG Java documentation (http://www.swig.org) for help.\n" + e);
      System.exit(1);
    }
  }


   //------------------------------------------------------------
   // METODOS
   //------------------------------------------------------------

	public WallEExplorer(String[] argv)
	{
		Aria.init();
		conn = new ArSimpleConnector(argv);
		WallE = new ArRobot();
		 touchSensor = new ();
		WallE.addRangeDevice(touchSensor );
		if(!Aria.parseArgs())
        {
          Aria.logOptions();
          Aria.shutdown();
          System.exit(1);
        }

        if (!conn.connectRobot(robot))
        {
          System.err.println("Could not connect to robot, exiting.\n");
          System.exit(1);
        }
		
		WallE.runAsync(true);
					
							WallE.move( 100	);
							
							 while (true)
							{	
								explorar();	
								esquivar();	
							}

	}
			private void explorar()
			{
				
				WallE.move( 100);

			
				
				
				ArUtil.sleep(200); 
			}
			private void esquivar()
			{
				
					if(  touchSensor.isPressed(-70,70)-400=true	      )
					{
							WallE.disableMotors( 0);
					}

			
				
				
				ArUtil.sleep(200); 
			}
    public static void main(String[] args) {
  	 WallEExplorer sm=new WallEExplorer(args);
  	}



} 



